Structural history schema authority#57
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a GraphQL structural-history schema with manifest, a checker script, and tests; and implements MCP workspace open/list-opened end-to-end (contracts, Zod output schemas, ToolContext wiring, tool definitions, workspace-router tracking/activation, and unit/playback tests). ChangesStructural History Schema and Validation
MCP Workspace Open / List-Opened
Sequence diagram (MCP workspace open/list flow): sequenceDiagram
participant Client
participant ToolRegistry
participant WorkspaceOpenTool
participant WorkspaceRouter
participant Storage
Client->>ToolRegistry: invoke workspace_open(cwd, activate?)
ToolRegistry->>WorkspaceOpenTool: dispatch to handler
WorkspaceOpenTool->>WorkspaceRouter: ctx.openWorkspace(request)
WorkspaceRouter->>Storage: resolve workspace & persist openedWorkspaces
Storage-->>WorkspaceRouter: persistence result
WorkspaceRouter-->>WorkspaceOpenTool: WorkspaceOpenResult
WorkspaceOpenTool-->>Client: respond("workspace_open", payload)
🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89a7641b90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@coderabbitai review please |
🧩 Analysis chain🏁 Script executed: Length of output: 111667
🔴 Hard-coded
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@schemas/graft-structural-history.manifest.json`:
- Around line 8-18: The manifest's requiredTypes array is missing
StructuralSourceSpan, so add "StructuralSourceSpan" to the requiredTypes list in
the manifest (the requiredTypes JSON array) to ensure artifact verification
enforces that canonical type; update the array alongside existing entries like
"StructuralRepository", "StructuralBasis", "StructuralFileVersion", etc.,
preserving JSON formatting and commas.
In `@scripts/check-structural-history-schema-artifacts.ts`:
- Around line 112-114: Replace the hard-coded expected version string with a
single exported constant and use that constant everywhere; create and export
(e.g. EXPECTED_WESLEY_CLI_VERSION or WESLEY_CLI_VERSION) from a shared module
(or from scripts/check-structural-history-schema-artifacts.ts if you prefer a
central export) and then update the check that compares
manifest.wesleyCliVersion (the if block that pushes to violations) to use that
exported constant, and update the contract test to import and assert against the
same constant so there is a single source of truth.
- Around line 82-84: The code builds a RegExp from manifest.requiredTypes
without escaping, which allows malformed manifest strings to produce invalid
regexes; update the typePattern function (and any call sites that interpolate
requiredTypes) to escape regex metacharacters in typeName before constructing
new RegExp (e.g. replace characters like . * + ? ^ $ { } ( ) | [ ] \ / with
escaped versions) so the literal type names are matched safely and do not throw;
keep the existing pattern structure (matching "export (interface|type)
<typeName>\\b" with the "u" flag) after escaping.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d9958cab-bc97-4030-a8e5-7c1a64bfd289
⛔ Files ignored due to path filters (6)
CHANGELOG.mdis excluded by!**/*.mddocs/design/CORE_structural-history-schema-and-echo-migration.mdis excluded by!**/*.mddocs/method/backlog/bad-code/CLEAN_wesley-cli-not-hermetic-in-graft-ci.mdis excluded by!**/*.mddocs/method/backlog/dependency-dag.dotis excluded by!**/*.dotdocs/method/backlog/dependency-dag.svgis excluded by!**/*.svgsrc/generated/graft-structural-history.tsis excluded by!**/generated/**
📒 Files selected for processing (6)
eslint.config.jspackage.jsonschemas/graft-structural-history.graphqlschemas/graft-structural-history.manifest.jsonscripts/check-structural-history-schema-artifacts.tstest/unit/contracts/graft-structural-history-schema.test.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/mcp/context.ts`:
- Around line 97-98: The type guard assertToolContext was not updated to check
the new required methods on ToolContext, so callers can pass a context missing
openWorkspace or listOpenedWorkspaces; update assertToolContext to verify the
presence and function-ness of openWorkspace and listOpenedWorkspaces (alongside
the existing checks) and throw/assert if they are absent or not functions;
reference the ToolContext interface and ensure the guard checks the methods
named openWorkspace and listOpenedWorkspaces so partially-wired contexts fail
fast.
In `@src/mcp/workspace-router.ts`:
- Around line 742-762: The changed calculation in noteOpenedWorkspace is done
before normalizing source and ignores capabilityProfile, causing incorrect
diffs; update the logic in noteOpenedWorkspace (the changed variable
computation) to first determine the effectiveSource exactly as is later used
(i.e., treat current?.source === "startup" as persistent) and then compute
changed by comparing current?.repoId, current?.worktreeRoot,
current?.gitCommonDir, current?.source (or the effectiveSource) and
current?.capabilityProfile against resolved capabilityProfile so
capabilityProfile differences are detected; then proceed to set openedWorkspaces
using the same effectiveSource and capabilityProfile to keep detection and state
consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5d6be24b-f354-4746-9ba8-ebb5fde6fe6c
⛔ Files ignored due to path filters (5)
docs/design/SURFACE_opened-workspace-paths.mdis excluded by!**/*.mddocs/method/backlog/cool-ideas/SURFACE_opened-workspace-paths.mdis excluded by!**/*.mddocs/method/backlog/dependency-dag.dotis excluded by!**/*.dotdocs/method/backlog/dependency-dag.svgis excluded by!**/*.svgdocs/three-surface-capability-matrix.mdis excluded by!**/*.md
📒 Files selected for processing (19)
src/contracts/capabilities.tssrc/contracts/output-schema-fragments.tssrc/contracts/output-schema-mcp.tssrc/contracts/output-schemas.tssrc/mcp/burden.tssrc/mcp/context.tssrc/mcp/repo-tool-worker-context.tssrc/mcp/server-context.tssrc/mcp/server-tool-access.tssrc/mcp/tool-registry.tssrc/mcp/tools/workspace-list-opened.tssrc/mcp/tools/workspace-open.tssrc/mcp/workspace-router-model.tssrc/mcp/workspace-router.tstest/unit/contracts/capabilities.test.tstest/unit/contracts/output-schemas.test.tstest/unit/mcp/opened-workspaces.test.tstests/playback/0078-three-surface-capability-baseline-and-parity-matrix.test.tstests/playback/SURFACE_capability-matrix-truth.test.ts
✅ Files skipped from review due to trivial changes (3)
- src/mcp/tools/workspace-list-opened.ts
- src/mcp/burden.ts
- src/mcp/server-tool-access.ts
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/mcp/workspace-router.ts (1)
110-119:⚠️ Potential issue | 🟠 Major | ⚡ Quick winInclude
runtimeLogsin capability-profile equality.
workspaceCapabilityProfilesEqual()still missesruntimeLogs, so a runtime-logs-only capability change can be treated as equal. That lets Line 324 skip the rebind path whilenoteOpenedWorkspace()updates the advertised profile, leavingcurrentBinding.capabilityProfileand the returned/opened view out of sync.🔧 Minimal fix
function workspaceCapabilityProfilesEqual( left: WorkspaceCapabilityProfile, right: WorkspaceCapabilityProfile, ): boolean { return left.boundedReads === right.boundedReads && left.structuralTools === right.structuralTools && left.precisionTools === right.precisionTools && left.stateBookmarks === right.stateBookmarks + && left.runtimeLogs === right.runtimeLogs && left.runCapture === right.runCapture; }Also applies to: 324-327, 764-769
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/mcp/workspace-router.ts` around lines 110 - 119, workspaceCapabilityProfilesEqual currently omits the runtimeLogs field so capability changes that only toggle runtimeLogs are treated equal; update workspaceCapabilityProfilesEqual to include left.runtimeLogs === right.runtimeLogs and then replace any ad-hoc comparisons (e.g., the spots that decide whether to rebind in noteOpenedWorkspace and where currentBinding.capabilityProfile is compared) to use this function so runtimeLogs changes trigger the rebind/path update and keep currentBinding.capabilityProfile and the returned/opened view in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/playback/SURFACE_opened-workspace-paths.test.ts`:
- Around line 8-12: The afterEach cleanup loop currently stops if a cleanup
callback throws; update the afterEach block that iterates over the cleanups
array (the while loop using cleanups.pop()!()) so each callback is invoked
inside a try/catch (or similar per-callback error handling) to log or ignore the
individual error and continue running remaining cleanup functions; ensure the
loop still removes each callback from cleanups (so no duplicates remain) even
when a callback throws.
---
Duplicate comments:
In `@src/mcp/workspace-router.ts`:
- Around line 110-119: workspaceCapabilityProfilesEqual currently omits the
runtimeLogs field so capability changes that only toggle runtimeLogs are treated
equal; update workspaceCapabilityProfilesEqual to include left.runtimeLogs ===
right.runtimeLogs and then replace any ad-hoc comparisons (e.g., the spots that
decide whether to rebind in noteOpenedWorkspace and where
currentBinding.capabilityProfile is compared) to use this function so
runtimeLogs changes trigger the rebind/path update and keep
currentBinding.capabilityProfile and the returned/opened view in sync.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9897586a-727c-4fa6-a639-04855f41ea6d
⛔ Files ignored due to path filters (3)
docs/design/SURFACE_opened-workspace-paths.mdis excluded by!**/*.mddocs/method/retro/SURFACE_opened-workspace-paths/SURFACE_opened-workspace-paths.mdis excluded by!**/*.mddocs/method/retro/SURFACE_opened-workspace-paths/witness/verification.mdis excluded by!**/*.md
📒 Files selected for processing (4)
src/mcp/tool-registry.tssrc/mcp/tools/workspace-open.tssrc/mcp/workspace-router.tstests/playback/SURFACE_opened-workspace-paths.test.ts
|
@codex Self-code-review pass against
Suggested repair order: #1, #2, #3, then docs/witness cleanup (#4-#8). |
|
To use Codex here, create an environment for this repo. |
|
@codex Follow-up self-review fixes pushed in Resolution summary:
Validation run locally:
|
|
To use Codex here, create an environment for this repo. |
|
@codex Self-discovered issue found during closure validation after resolving review threads.
|
|
To use Codex here, create an environment for this repo. |
|
@codex Activity Summary for Code Lawyer repair pass.
Validation:
Merge-gate note: checks are green and there are zero Changes Requested reviews, but the PR still has 0 approvals. The gate remains locked until the required 2 approvals arrive. |
|
To use Codex here, create an environment for this repo. |
Summary
Verification
Summary by CodeRabbit
New Features
Chores
Tests